package edu.pe.cayetano.view.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.apache.commons.beanutils.RowSetDynaClass;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import ws.synopsis.frmwrk.common.BResult;
import edu.pe.cayetano.model.bo.PeriodoAcademicoBO;
import edu.pe.cayetano.seccd.constantes.ConstantesSECCD;
import edu.pe.cayetano.util.EscribeLog;
import edu.pe.cayetano.util.UtilitarioSession;

public class PeriodoAcademicoAction extends BaseAction{
	
	private String page	= ConstantesSECCD.EXITO;
	
	public ActionForward listar(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response){
		BResult						ret			= new BResult();
		PeriodoAcademicoBO			perAcadBO 	= new PeriodoAcademicoBO();
		try {
			HttpSession session = request.getSession(false);
			ret = perAcadBO.listarPeriodoAcademico();
			if(ret.getCode()==0 && ret.getObject()!=null){
				page=ConstantesSECCD.EXITO;
				UtilitarioSession.eliminaParametrosBusquedaGenerico(session);
				UtilitarioSession.seteaParametrosListadoGenerico(session,(RowSetDynaClass)ret.getObject());
			}else{
				page=ConstantesSECCD.ERROR;
				EscribeLog.escribeLog("PeriodoAcademicoAction","listar",ConstantesSECCD.ERROR,ret.getMessage());
				mostrarMensaje(request,ConstantesSECCD.ERROR_PERACADEMICO_LISTAR,new String[0],"home.do","home");
			}
		}catch (Exception e) {
			page=ConstantesSECCD.ERROR;
			EscribeLog.escribeLog("PeriodoAcademicoAction","listar",ConstantesSECCD.ERROR,ret.getMessage());
			mostrarMensaje(request,ConstantesSECCD.ERROR_PERACADEMICO_LISTAR,new String[0],"home.do","home");
		}
		return mapping.findForward(page);	
	}
}
